<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>研究进程（老师）---中期报告</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
    <style>
        .mbox {
            padding: 8px
        }

        .item img {
            height: 40px;
        }

        .btn {
            height: 30px;
        }

        .btn button {
            float: right;
        }

        .information {
            background: #e8f4fc;
            height: 30px;
            line-height: 30px;
        }

        .layui-form-label {
            width: 77px;
        }

        .openFile input[type=file] {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 18px;
            z-index: 99;
            opacity: 0;
        }

        .layui-table-cell .layui-form-checkbox[lay-skin=primary] {
            top: 5px;
        }
    </style>
</head>
<body>
<div class="mbox">
    <div class="item">
        <img src="../img/yeji.png" alt="" style="margin: 0 5px 0 20px;"> <span
            style="font-size: 22px;display: inline-block;vertical-align: middle;">研究进程（老师）</span>
    </div>
    <hr class="layui-bg-blue">
    <div class="btn">
        <button type="button" class="layui-btn layui-btn-sm" style="background: #2b7fe0"><i
                class="layui-icon layui-icon-upload-drag" style="background: #2b7fe0"></i>导出Excel
        </button>
        <button type="button" class="layui-btn layui-btn-sm" id="addition"
                style="background: #2b7fe0;margin-right: 20px"><i class="layui-icon layui-icon-addition"
                                                                  style="vertical-align: inherit"></i>查询
        </button>
    </div>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
</body>
</html>
<script type="text/html" id="barDemo">
    {{# if(d.trStatus==3 || d.trStatus==6){ }}
    <a class="layui-btn layui-btn-xs" lay-event="score">填写</a>
    {{# }else{ }}
    <a class="layui-btn layui-btn-xs" style="cursor: not-allowed;background: #C1C1C1">填写</a>
    {{# } }}
</script>
<script>
    layui.use(['table', 'form', 'laydate'], function () {
        var table = layui.table,
            form = layui.form,
            laydate = layui.laydate
        var tableIns = null

        function tableShow() {
            tableIns = table.render({
                elem: '#test'
                , url: '/process/ResearchProcessExamine1'
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                , cols: [[
                    {type: 'checkbox'}
                    , {field: 'topicName', title: '项目名称'}
                    , {field: 'planName', title: '申报计划名称'}
                    , {field: 'participantName', title: '项目成员'}
                    , {field: 'userName', title: '负责人'}
                    , {field: 'trStatus', title: '审批状态',templet:function (d) {
                            if(d.trStatus==1){
                                return '待审批'
                            }else if(d.trStatus==2){
                                return '已批准'
                            }else if(d.trStatus==3){
                                return '未批准'
                            }else{
                                return ''
                            }
                        }}
                    , {title: '操作', toolbar: '#barDemo'}
                ]]
                , page: true,
                where: {useFlag: true},
                parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": 0, //解析接口状态
                        "count": res.totleNum, //解析数据长度
                        "data": res.obj //解析数据列表
                    };
                }
            });
        }

        tableShow()

        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event === 'score') {
                /*$.get('/process/getStatus1',{topicId:data.topicId,trType:33},function (res) {
                    if(res==6 || res==3){
                        layer.open({
                            type: 2,
                            title: '填写',
                            btn: ['确定', '取消'],
                            shade: 0.5,
                            area: ['100%', '100%'],
                            content: '/rpmPlan/researchProcessUE_InterimReport',
                            yes: function (index, layero) {
                                // var $fileAll = layer.getChildFrame('body', index).find('#fileAll')
                                var $fileAll2 = layer.getChildFrame('body', index).find('#fileAll2')
                                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                                // var trOther = iframeWin.ue.getContent()
                                var trOther2 = iframeWin.ue2.getContent()
                                //开题报告
                                /!* var trOther3 = '';
                                 var trOther4 = '';
                                 for (var i = 0; i < $fileAll.find('.dech').length; i++) {
                                     trOther3 += $fileAll.find('.dech').eq(i).find('input').val();
                                     trOther4 += $fileAll.find('a').eq(i).attr('name');
                                 }*!/
                                //中期报告
                                var trOther5 = '';
                                var trOther6 = '';
                                for (var i = 0; i < $fileAll2.find('.dech').length; i++) {
                                    trOther5 += $fileAll2.find('.dech').eq(i).find('input').val();
                                    trOther6 += $fileAll2.find('a').eq(i).attr('name');
                                }
                                $.post('/process/ResearchProcessWrite2',
                                    {topicId:data.topicId,trOther2: trOther2,trOther5:trOther5,trOther6:trOther6},
                                    function (res) {
                                        if(res.flag){
                                            layer.msg('保存成功！',{icon:1});
                                            layer.close(index)
                                            tableIns.config.where._ = new Date().getTime();
                                            tableIns.reload()
                                        }
                                    })
                            }
                        })
                    }else{
                        layer.msg('该项目已提交审核，不可操作！',{icon:0});
                    }
                })*/
                layer.open({
                    type: 2,
                    title: '填写',
                    btn: ['确定', '取消'],
                    shade: 0.5,
                    area: ['100%', '100%'],
                    content: '/rpmPlan/researchProcessUE_InterimReport',
                    yes: function (index, layero) {
                        // var $fileAll = layer.getChildFrame('body', index).find('#fileAll')
                        var $fileAll2 = layer.getChildFrame('body', index).find('#fileAll2')
                        var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                        // var trOther = iframeWin.ue.getContent()
                        var trOther2 = iframeWin.ue2.getContent()
                        //开题报告
                        /* var trOther3 = '';
                         var trOther4 = '';
                         for (var i = 0; i < $fileAll.find('.dech').length; i++) {
                             trOther3 += $fileAll.find('.dech').eq(i).find('input').val();
                             trOther4 += $fileAll.find('a').eq(i).attr('name');
                         }*/
                        //中期报告
                        var trOther5 = '';
                        var trOther6 = '';
                        for (var i = 0; i < $fileAll2.find('.dech').length; i++) {
                            trOther5 += $fileAll2.find('.dech').eq(i).find('input').val();
                            trOther6 += $fileAll2.find('a').eq(i).attr('name');
                        }
                        $.post('/process/ResearchProcessWrite2',
                            {topicId:data.topicId,trOther2: trOther2,trOther5:trOther5,trOther6:trOther6},
                            function (res) {
                                if(res.flag){
                                    layer.msg('保存成功！',{icon:1});
                                    layer.close(index)
                                    tableIns.config.where._ = new Date().getTime();
                                    tableIns.reload()
                                }
                            })
                    }
                })
            }
        });
    });
</script>